#!/usr/bin/env python

from subprocess import Popen,PIPE
import os
import sys
import re

VM=['8','9']

def get_vm_ip(VM_LIST):
    if not VM_LIST:
        return 0
    show_cmd="/srv/cloud/one/bin/onevm"
    IP_LIST=[]
    for each in VM_LIST:
        fp=Popen((show_cmd,'show',each),stdout=PIPE).stdout
        date=fp.read().strip()
        fp.close()
        patt='IP=([\.0-9]*)'
        p=re.search(patt,date)
        if p:
            print p.group(1)
            
get_vm_ip(VM)
